package com.wechatapp.mengyao.poetry.vo;

import com.fasterxml.jackson.annotation.JsonFilter;
import com.fasterxml.jackson.core.type.TypeReference;
import com.wechatapp.mengyao.poetry.core.JsonUtils;
import lombok.Data;
import org.springframework.util.StringUtils;

import java.util.List;

@Data
@JsonFilter("ChinesePoetryDTOFilter")
public class ChinesePoetryView {

    private Integer id;

    private String author;

    private Integer authorId;

    private String authDescription;

    private String dynasty;

    private String title;

    private String rhythmic;

    private String chapter;

    private String notes;

    private String collection;

    private String section;

    private String contentString;

    private List<ChinesePoetryContentView> content;

    private String comment;

    private String tagString;

    private List<String> tags;

    private String isFavorite;

    private String filePath;

    private String translation;

    /**
     * 是否有拼音
     */
    private boolean withPinyin;

    public ChinesePoetryView convert() {
        if (StringUtils.hasText(this.tagString)) {
            this.tags = JsonUtils.parseList(this.tagString, new TypeReference<List<String>>() {
            });
        }
        return this;
    }

}